package hust.music.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import hust.music.action.base.ActionBase;
import hust.music.entity.Music;
import hust.music.entity.PlayList;
import hust.music.entity.User;
import hust.music.service.PlayListModService;
import hust.music.util.DateConvert;
import hust.music.util.DynamicInfo;

/**
 * PlayListAction
 * 
 * @author Txazo
 * @since 1.0
 */
@Controller
@Scope("session")
public class PlayListAction extends ActionBase {

	private static final long serialVersionUID = 1L;

	/** 流派集Id */
	private Integer id;

	/** 流派集歌曲总数 */
	private int count;

	/** 用户 */
	private User user;
	/** 流派集 */
	private PlayList playList;
	/** 其它流派集 */
	private List<DynamicInfo> otherPlayList;
	/** 流派集歌曲 */
	private List<Music> music;

	@Autowired
	private PlayListModService playListModService;

	/**
	 * 流派集
	 * 
	 * @return 逻辑视图
	 * @throws Exception
	 */
	public String execute() throws Exception {
		playList = playListModService.getPlayList(id);

		count = playListModService.getTotalMusicCount(playList);

		user = playListModService.getUser(playList);

		otherPlayList = playListModService.getOtherPlayList(user, playList);

		music = playListModService.getMusic(playList);
		for (Music m : music) {
			System.out.println(m.getTitle());
			System.out.println(DateConvert.convertDateToString(m
					.getUploadTime()));
		}

		return SUCCESS;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public PlayList getPlayList() {
		return playList;
	}

	public void setPlayList(PlayList playList) {
		this.playList = playList;
	}

	public List<Music> getMusic() {
		return music;
	}

	public void setMusic(List<Music> music) {
		this.music = music;
	}

	public List<DynamicInfo> getOtherPlayList() {
		return otherPlayList;
	}

	public void setOtherPlayList(List<DynamicInfo> otherPlayList) {
		this.otherPlayList = otherPlayList;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

}